home *** CD-ROM | disk | FTP | other *** search
- Path: news.microsoft.com!news
- From: a-cnadc@microsoft.com (Dann Corbit)
- Newsgroups: comp.lang.c
- Subject: Re: Why is Gets() so bad?
- Date: 4 Mar 1996 19:19:16 GMT
- Organization: Microsoft Corporation
- Message-ID: <4hffnk$m6e@news.microsoft.com>
- References: <4hb1ie$pa7@ixnews2.ix.netcom.com>
- NNTP-Posting-Host: 157.57.171.202
- Mime-Version: 1.0
- X-Newsreader: WinVN 0.93.14
-
- In article <4hb1ie$pa7@ixnews2.ix.netcom.com>, studwoof@ix.netcom.co says...
- >
- >Hi.. I'm not a newbie.. I don't even use Gets(), fgets(), or scanf.. I
- >use my own getstring function. My question is that everywhere I see
- >that gets() is bad. Why exactly is it so bad? Could someone please
- >explain in more detail than what the FAQ does? Thanks.
- A big problem with gets() is that it does not know how big your input
- string is. So if you have a string 12 bytes long, and you read in 13,
- you are doing a tap dance on your data. The fgets() function knows how
- big your data object is (unless you lie to it) and is therefore much
- safer.
- --
- The opinions expressed in this message are my own personal views
- and do not reflect the official views of Microsoft Corporation.
- In fact, I'm just a subcontractor, not an employee, so pull in your claws.
-
-